﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using CarLeasing.Models;

namespace CarLeasing.Forms.Controls
{
    public partial class CarInfoListPanel : UserControl
    {
        public CarInfoListPanel()
        {
            InitializeComponent();
        }

        private void CarInfoListPanel_Load(object sender, EventArgs e)
        {
            carInfoList.CarSelected += carDetailView.ShowCar;
            carInfoList.CarSelected += c => CarSelected?.Invoke(c);
        }

        public void LoadCarInfos(CarInfo[] carInfos) => carInfoList.LoadCarInfos(carInfos);

        public event Action<CarInfo> CarSelected;
    }
}
